In college I had an assignment to draw fractals. When I started working at REAL Software, I thought it would be fun to do it using REALbasic. I had it working in REALbasic in about an hour. I had added threads, zooming (just click the start point and end point of the rectangle you want to zoom on), and drag and drop in a couple of more hours. All in all it was great, but it was slow.
I set about to optimize the code.
I removed the complex class and used X and Y instead.
I in-lined the complexsquare function
I in-lined the iterate function
I used singles instead of doubles (this is slightly faster on PowerPC, but much slower on 68k)
I drew into an offscreen picture
it only took me about 3 hours to get the wonderful results below.
Results (on a 400 X 400 sample):
Optimized C (Built PPC): 0.900 seconds
Optimized REALbasic (Built PPC): 0.916 seconds
Non opt. REALbasic (Built PPC): 6.483 seconds
Tests were run on a 400 MHz G4, VM on.
C compiled with Metrowerks Codewarrior 4.02
REALbasic apps built with 2.1 beta 5
All tests were run with threading turned off.
Note: This example compiles for 68k and Win32 just fine. In Win32 the drag and drop doesn't work.